﻿using System.IO;
using System.Text;

namespace ShpViewer
{
    public class BoundingBox
    {
        public double xMin { get; set; }
        public double yMin { get; set; }
        public double xMax { get; set; }
        public double yMax { get; set; }
        public double zMin { get; set; }
        public double zMax { get; set; }
        public double mMin { get; set; }
        public double mMax { get; set; }

        public BoundingBox()
        {
            xMin = double.MaxValue;
            yMin = double.MaxValue;
            xMax = double.MinValue;
            yMax = double.MinValue;
            zMin = double.MaxValue;
            zMax = double.MinValue;
            mMin = double.MaxValue;
            mMax = double.MinValue;
        }

        public void Read(BinaryReader binaryReader)
        {
            xMin = binaryReader.ReadDouble();
            yMin = binaryReader.ReadDouble();
            yMin = 0 - yMin;
            xMax = binaryReader.ReadDouble();
            yMax = binaryReader.ReadDouble();
            yMax = 0 - yMax;
            zMin = binaryReader.ReadDouble();
            zMax = binaryReader.ReadDouble();
            mMin = binaryReader.ReadDouble();
            mMax = binaryReader.ReadDouble();
        }

        public override string ToString()
        {
            StringBuilder stringbuilder = new StringBuilder();
            stringbuilder.AppendFormat("xMin={0}", xMin).AppendLine();
            stringbuilder.AppendFormat("xMax={0}", xMax).AppendLine();
            stringbuilder.AppendFormat("yMin={0}", yMin).AppendLine();
            stringbuilder.AppendFormat("yMax={0}", yMax).AppendLine();
            stringbuilder.AppendFormat("zMin={0}", zMin).AppendLine();
            stringbuilder.AppendFormat("zMax={0}", zMax).AppendLine();
            stringbuilder.AppendFormat("mMin={0}", mMin).AppendLine();
            stringbuilder.AppendFormat("mMax={0}", mMax).AppendLine();
            return stringbuilder.ToString();
        }
    }
}
